package com.ssy.lingxi.order.model.vo.basic.request;

import com.ssy.lingxi.order.handler.annotation.DateTimeFormatAnnotation;
import com.ssy.lingxi.order.handler.annotation.PromotionBelongTypeAnnotation;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * 订单商品关联的优惠券
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-23
 */
public class OrderCouponVO implements Serializable {
    private static final long serialVersionUID = -4511088706663002252L;

    /**
     * 优惠券归属的供应会员（店铺）Id
     */
    @NotNull(message = "优惠券归属的供应会员（店铺）Id要大于0")
    @Positive(message = "优惠券归属的供应会员（店铺）Id要大于0")
    private Long vendorMemberId;

    /**
     * 优惠券归属的供应会员（店铺）角色Id
     */
    @NotNull(message = "优惠券归属的供应会员（店铺）Id要大于0")
    @Positive(message = "优惠券归属的供应会员（店铺）Id要大于0")
    private Long vendorRoleId;

    /**
     * 优惠券适用商品的SkuId，如果不是商品优惠券，为空或Null或0
     */
    private Long skuId;

    /**
     * 优惠券Id
     */
    @NotNull(message = "优惠券Id要大于0")
    @Positive(message = "优惠券Id要大于0")
    private Long couponId;

    /**
     * 优惠券名称
     */
    @NotBlank(message = "优惠券名称不能为空")
    @Size(max = 60, message = "优惠券名称最长60个字符")
    private String name;

    /**
     * 优惠券类型枚举
     */
    @NotNull(message = "优惠券类型要大于0")
    @Positive(message = "优惠券类型要大于0")
    private Integer couponType;

    /**
     * 优惠券归属类型枚举
     */
    @NotNull(message = "优惠券归属类型要大于0")
    @PromotionBelongTypeAnnotation(message = "优惠券归属类型不在定义范围内")
    private Integer belongType;

    /**
     * 优惠券面额
     */
    @NotNull(message = "优惠券面额要大于0")
    @Positive(message = "优惠券面额要大于0")
    private BigDecimal amount;

    /**
     * 优惠券有效期起始时间，格式为 yyyy-MM-dd HH:mm:ss
     */
    @NotBlank(message = "优惠券有效期起始时间不能为空")
    @DateTimeFormatAnnotation(message = "优惠券有效期起始时间格式错误")
    private String startTime;

    /**
     * 优惠券有效期结束时间，格式为 yyyy-MM-dd HH:mm:ss
     */
    @NotBlank(message = "优惠券有效期结束时间不能为空")
    @DateTimeFormatAnnotation(message = "优惠券有效期结束时间格式错误")
    private String expireTime;

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public Long getCouponId() {
        return couponId;
    }

    public void setCouponId(Long couponId) {
        this.couponId = couponId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCouponType() {
        return couponType;
    }

    public void setCouponType(Integer couponType) {
        this.couponType = couponType;
    }

    public Integer getBelongType() {
        return belongType;
    }

    public void setBelongType(Integer belongType) {
        this.belongType = belongType;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(String expireTime) {
        this.expireTime = expireTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        OrderCouponVO that = (OrderCouponVO) o;
        return Objects.equals(couponId, that.couponId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(couponId);
    }
}
